<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
  <title>公会房间</title>
  <link rel="stylesheet" href="/mobile/css/index.css" />
  <script src="/mobile/js/vue.js"></script>
  <script src="/mobile/js/vue-infinite-scroll.js"></script>
  <script src="/mobile/js/axios.min.js"></script>
  <script src="/mobile/js/vant.min.js"></script>
  <script src="/mobile/js/crypto-js.js"></script>
  <script src="/mobile/js/aes.js"></script>
  <script src="/mobile/js/common.js"></script>
  <style>
  * {
    margin: 0;
    padding: 0;
    -webkit-user-select: none;
    /* Safari */
    -moz-user-select: none;
    /* Firefox */
    -ms-user-select: none;
    /* IE10+/Edge */
    user-select: none;
    /* Standard syntax */
    list-style: none;
  }

  #app {
    padding: 10px;
    background: #05071D;
    min-height: 100vh;
    box-sizing: border-box;
    background-repeat: no-repeat;
    background-position: top center;
    background-size: contain;
  }

  .room-item {
    padding: 20px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
  }
  .room-item:not(:last-child) {
    border-bottom: 1px solid #eee;
  }

  .room-left {
    display: flex;
    max-width: 70vw;
  }
  .room-info {
    margin-left: 15px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
  }
  .room-icon {
    width: 70px;
    height: 70px;
    border-radius: 5px;
    overflow: hidden;
    object-fit: cover;
  }
  .room-name {
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
  }
  .living {
    display: flex;
    align-items: center;
    background: linear-gradient( 270deg, #9358F4 0%, #6E53F3 100%);
    border-radius: 10px;
    font-size: 10px;
    padding-right: 5px;
    margin-left: 10px;
  }
  .room-desc {
    font-size: 12px;
    color: #A9ABCA;
  }
  .room-member {
    font-size: 12px;
    color: #A9ABCA;
  }
  .pretty-id {
    display: inline-block;
    background: #ff0000;
    color: #fff;
    font-size: 12px;
    padding: 0 2px;
    margin-right: 5px;
  }
  .van-empty__image {
    width: 200px;
    height: 150px;
  }

  </style>
</head>

<body>
  <div id="app">
    <template v-if="!list.length">
      <van-empty
        class="custom-image"
        image="/mobile/img/empty.png"
        description="暂无数据"
      />
    </template>
    <div v-else class="room-item" v-for="(item, index) in list" :key="index">
      <div class="room-left">
        <van-image class="room-icon" :src="item.thumb +'?x-oss-process=image/resize,h_160,m_fill/format,jpg'">
          <template v-slot:error>
            <img class="room-icon" :src="item.thumb" alt="">
          </template>
        </van-image>
        
        <div class="room-info">
          <div class="room-name">
            <span>{{item.title}}</span>
            <div class="living" v-if="item.live === 1">
              <img src="/mobile/img/icon_playing.gif" alt="" width="16" height="16">
              <span>直播中</span>
            </div>
          </div>
          <div class="room-member"><span class="pretty-id">靓</span>{{item.goodNum}}</div>
          <div class="room-member">厅主：{{item.uuserNickname}}（{{item.ugoodNum}}）</div>
        </div>
      </div>
    </div>
  </div>
  <script>
  new Vue({
    el: '#app',
    data: {
      id: '',
      token: '',
      list: [],
    },
    created() {
      const parse = (queryStr) => {
        const str = queryStr.replace(/^\?/, '')
        return str.split('&').reduce((pre, key) => {
          const [k, v] = key.split('=')
          pre[decodeURIComponent(k)] = decodeURIComponent(v)
          return pre
        }, {})
      }
      var data = parse(location.search)
      console.log(data)
      if (data.token) {
        this.token = data.token
        this.getData()
      }
    },
    methods: {
      getData() {
        this.$toast.loading({
          overlay: true,
          forbidClick: true,
          duration: 0
        })
        request.get(`/api/business/app/family/getFamilyRoomList`, {
          headers: {
            token: this.token,
          }
        }).then(res => {
          console.log(res)
          this.list = res.data
        }).finally(() => {
          this.$toast.clear()
        })
      },
    }
  })
  </script>
</body>

</html>